<?php
/**
 * Created by PhpStorm.
 * User: dung
 * Date: 11/11/14
 * Time: 10:49 AM
 */

class Lyric extends Eloquent
{

    use SoftDeletingTrait;

    protected $dates = ['deleted_at'];

    public function author()
    {
        return $this->belongsTo('User', 'user_id');
    }

    public function tone()
    {
        return $this->belongsTo('Tone', 'tone_id');

    }

    public function category()
    {
        return $this->belongsTo('Category', 'category_id');
    }

    public function topics()
    {
        return $this->belongsToMany('Topic', 'topicables', 'lyric_id', 'topic_id');
    }

    public function tags()
    {
        return $this->belongsToMany('Tag', 'taggable', 'lyric_id', 'tag_id');
    }

    public function singer()
    {
        return $this->belongsTo('Singer', 'singer_id');
    }

    public function musician()
    {
        return $this->belongsTo('Singer', 'musician_id');
    }

    public function favourites()
    {
        return $this->belongsToMany('User', 'favourites', 'lyric_id', 'user_id');
    }

    public function thanks()
    {
        return $this->belongsToMany('User', 'thanks', 'lyric_id', 'user_id');
    }

//    public function fullScreenLink()
//    {
//        return route('fs-hop-am-chi-tiet', array('id' => $this->id, 'slug' => $this->slug));
//    }

    public function fullScreenLink()
    {
        return route('chi-tiet-hop-am', array('id' => $this->id, 'slug' => $this->slug,'mode'=>'fullscreen'));
    }

    public function generate_link()
    {
        return route('chi-tiet-hop-am', array('id' => $this->id, 'slug' => $this->slug));
    }
} 